App({
  globalData: {
    // 播放音乐的文章id
    playPostId: '',
    // 是否音乐正在播放
    playing: false,
    // 豆瓣接口域名
    doubanBaseUrl: 'https://frodo.douban.com/api',
    ///api请求对应接口域名
    myApiBaseUrl:'http://www.hisicms.com/api',
  },
  onLaunch:function(e){
  },
  getAccessToken:function(){
        let self = this;
        return new Promise(function(resolve,reject){
          wx.checkSession({
            success () {
              //session_key 未过期，并且在本生命周期一直有效
              resolve('未过期');
            },
            fail () {
              console.log();
              // session_key 已经失效，需要重新执行登录流程
              wx.login({
                timeout: 5000,
                success(res){
                  if (res.code) {
                    wx.request({
                      url: `${self.globalData.myApiBaseUrl}/login/login`,
                      data:{jscode:res.code},
                      success(response){
                        if(response.statusCode == 200 && response.data.token){
                          wx.setStorageSync('token', response.data.token);
                          resolve(res);
                        }
                      }
                    })
                  }else{
                    console.log('网络请求异常');
                    reject('fail');
                  }
                }
              })
            }
          })
        }
        )
      }
})